//
//  NSString+DeviceInfo.m
//  HSY
//
//  Created by 陈浩 on 2017/3/31.
//  Copyright © 2017年 金开门. All rights reserved.
//

#import "NSString+DeviceInfo.h"
#import "SAMKeychain.h"
#import "GeTuiSdk.h"

@implementation NSString (DeviceInfo)

+ (NSString *)uuid{
    //为了兼容老版本， 暂时先存着service : HSY_COMMON_FIELD_DEVICE_ID，以后使用钥匙串建议使用：kHSYKeyChainServerName
    NSString *uuid = [SAMKeychain passwordForService:HSY_COMMON_FIELD_DEVICE_ID account:@"UUID"];
    if (!uuid) {
        uuid = [UIDevice currentDevice].identifierForVendor.UUIDString;
        if (uuid) {
            [SAMKeychain setPassword:uuid forService:HSY_COMMON_FIELD_DEVICE_ID account:@"UUID"];
        }
    }
    return uuid;
}

+ (NSString *)appBuild{
    NSDictionary *infoDictionary  = [[NSBundle mainBundle] infoDictionary];
    return [infoDictionary objectForKey:@"CFBundleVersion"];
}

+ (NSString *)deviceName{
    return [UIDevice currentDevice].name;
}

+ (NSString *)deviceSystemVersion{
    return [UIDevice currentDevice].systemVersion;
}

+ (NSString *)clientId{
    return [GeTuiSdk clientId]?[GeTuiSdk clientId]:@"";
}
@end
